inference_type = "rvv"  # 'rvv' or 'npu'
init = False


def set_inference_type(def_type: str):
    global inference_type
    def_type = def_type.lower()
    inference_type = def_type if def_type == "npu" or def_type == "cpu" else "rvv"


def initialize():
    global init
    if not init:
        if inference_type == "rvv":
            # import core_with_yolox as core_
            import core_with_ultralytics as core_
        else:
            import core_with_npu as core_
        global core_
        init = True


def start_server_thread(port=8888):
    global core_
    core_.start_server_thread(port)


def start_detect_thread(video_path, detection_listener, interval, frame_interval):
    global core_
    core_.start_detect_thread(video_path, detection_listener, interval, frame_interval)


def stop_monitoring():
    global core_
    core_.stop_monitoring()
